<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<title>新闻发布系统管理后台</title>
<link href="news/css/admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="news/js/jquery-1.12.4.min.js"></script>
<script src="jquery.min.js"></script>
<script type="text/javascript">
	$(function(){
		$("#sub").prop("disabled",true);
		$("#name").blur(function(){
			var name=$("#name").val();
			if(name==""){
			$("#prompt").html("主题不能为空!");
			$("#sub").prop("disabled",true);
			return;
			}
			$.post("CheckTopicServlet",{tname:name},function(data){
				if(data=="false"){
					$("#prompt").html("主题重复!");
					$("#sub").prop("disabled",true);
				}else{
					$("#prompt").html("");
					$("#sub").prop("disabled",false);
				}
			
			},"text")
			
		})
		
		/* $("#submit").click(function(){
			var name=$("#name").val();
			if(name==""){
			$("#prompt").html("主题不能为空!");
				return false;
			}
			var isOk=true;
			$.ajax({
				url:"CheckTopicServlet",
				type:"post",
				data:{tname:name},
				dataType:"json",
				 async: false,
				 success:function(data){
				 	if(!data){
				 	isOk=false;
				 	}
				 }
			})
			if(!isOk){
			return false;
			}
		}) */
	})
	
</script>
</head>
<body>
	<jsp:include page="/AdminHeaderServlet"></jsp:include>
	<div id="main">
		<jsp:include page="/AdminLeftServlet"></jsp:include>

		<div id="opt_area">
			<h1 id="opt_type">添加主题：</h1>
			<form action="DoAddTopicServlet" method="post" >
			 <label>请输入新增分类名：</label><input type="text" id="name" name="tname" >
			 <input  type="submit" name="submit" value="提交" id="sub" >
			 <input  type="reset" name="reset" value="重置" >
			 <p>
			  <span style="margin-left:110px;color:red" id="prompt"></span>
			 </p>
			 </form>
		</div>
	</div>
	<jsp:include page="/AdminFooterServlet"></jsp:include>
</body>
</html>
